﻿/**
 *
 * @file FITKAbaqusHDF5AdaptorInteraction.h
 * @brief 读写HDF5文件的Interaction类
 * @author fulipeng (fulipengqd@yeah.net)
 * @date 2024-06-11
 *
 */
#ifndef  _FITKABAQUSHDF5ADAPTORINTERACTION_H__
#define  _FITKABAQUSHDF5ADAPTORINTERACTION_H__

#include "FITKAbaqusIOHDF5API.h"
#include "FITKAbaqusHDF5AbstractAdaptor.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITK_Interface/FITKInterfaceIOHDF5/FITKInterfaceHDF5AdaptorBoundaryLocation.h"

 //前置声明
ForwardDeclarNS(Interface, FITKAbaAbstractInteraction)
ForwardDeclarNS(Interface, FITKAbaInteractionGeneralContactExplicit)
ForwardDeclarNS(Interface, FITKAbaInteractionSurfToSurfExplicit)
ForwardDeclarNS(AbaqusData, FITKDataCase)

namespace IO
{
    /**
     * @brief HDF5 Interaction 读写适配器
     * @author fulipeng (fulipengqd@yeah.net)
     * @date 2024-06-11
     */
    class FITKABAQUSIOHDF5API FITKAbaqusHDF5AdaptorInteraction : public FITKInterfaceHDF5AdaptorBoundaryLocation
    {
    public:
        explicit FITKAbaqusHDF5AdaptorInteraction() = default;
        virtual ~FITKAbaqusHDF5AdaptorInteraction() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        QString getAdaptorClass() override;

        /**
         * @brief 设置数据结构
         * @param caseData 算例数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        void setDataCase(AbaqusData::FITKDataCase* caseData);

        /**
         * @brief 适配器读取
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool adaptW() override;

    protected:

        /**
         * @brief 读取相互作用
         * @param interaction 相互作用
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        virtual bool readInteraction(Interface::FITKAbaAbstractInteraction* interaction, H5::Group& h5Group);

        /**
         * @brief 读取通用接触相互作用
         * @param interaction 相互作用
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        bool readGeneralContactExplicit(Interface::FITKAbaAbstractInteraction* interaction, int stepID, H5::Group& h5Group);
        
        /**
         * @brief 读取面面相互作用
         * @param interaction 相互作用
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        bool readSurfToSurfExplicit(Interface::FITKAbaAbstractInteraction* interaction, int stepID, H5::Group& h5Group);

        /**
         * @brief 写出相互作用
         * @param interaction 相互作用
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        virtual bool writeInteraction(Interface::FITKAbaAbstractInteraction* interaction, H5::Group& h5Group);
        
        /**
         * @brief 写出通用接触相互作用
         * @param interaction 相互作用
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        bool writeGeneralContactExplicit(Interface::FITKAbaAbstractInteraction* interaction,int stepID, H5::Group& h5Group);

        /**
         * @brief 写出面面接触相互作用
         * @param interaction 相互作用
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        bool writeSurfToSurfExplicit(Interface::FITKAbaAbstractInteraction* interaction, int stepID, H5::Group& h5Group);

    private:

        /**
         * @brief 算例数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        AbaqusData::FITKDataCase* _caseData{};
    };

    Register2FITKIOAdaptorFactory(HDF5, Interface::FITKAbaAbstractInteraction, FITKAbaqusHDF5AdaptorInteraction)

}

#endif
